package actions;

import extra.Position;
import game.constants.ReferenceAction;
import game.constants.ReferenceSpecialFeature;
import interfaces.ActionInterface;
import interfaces.impl.Action;
import objects.SpetialFeature;
import universe.Universe;


public class ActionXYtoMove extends Action{
	
	private double xToMove;
	private double yToMove;
	
	

	@Override
	public boolean processActionChild(Universe world) {
		
		for(SpetialFeature fe : target.getListFeatures()){
			if(fe.getId()==ReferenceSpecialFeature.SPETIAL_FEATURE_X_TO_MOVE){
				fe.setValue(xToMove);
			}
			if(fe.getId()==ReferenceSpecialFeature.SPETIAL_FEATURE_Y_TO_MOVE){
				fe.setValue(yToMove);
			}
		}
		
		return false;
	}


	public double getxToMove() {
		return xToMove;
	}
	public void setxToMove(double xToMove) {
		this.xToMove = xToMove;
	}
	public double getyToMove() {
		return yToMove;
	}
	public void setyToMove(double yToMove) {
		this.yToMove = yToMove;
	}
	
	public void setPosition(Position pos){
		xToMove = pos.getX();
		yToMove = pos.getY();
	}

	@Override
	public void initializeName() {
		name="Action XY To move";
		
	}

	@Override
	public void initializeId() {
		this.id= ReferenceAction.ACTION_XY_TO_MOVE;
	}


	@Override
	public void modifyChild(ActionInterface action) {
		if (action instanceof ActionXYtoMove) {
			ActionXYtoMove ac = (ActionXYtoMove) action;
			xToMove=ac.xToMove;
			yToMove=ac.yToMove;
		}
		
	}
	
	@Override
	public ActionXYtoMove cloneAction(){
		ActionXYtoMove action = new ActionXYtoMove();
		action.modifyAction(this);
		return action;
		
	}

}
